<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<script type="text/javascript">
$(document).ready(function(){
if("${requestScope.modify}"=="수정"){
	$("#r_uploadFile").attr("src","${initParam.root }/upload/temp/${sessionScope.recipeContent.list[reviewOrder-1].r_img_new}");
}else{
	$("#r_uploadFile").attr("src","${initParam.imgRoot}${sessionScope.recipeContent.list[reviewOrder-1].r_img_new}");
}

//메인 이미지 클릭시 팝업 열기
$("#r_uploadFile").click(function(){
	window.open("${initParam.root }/recipe/imgPopup.jsp","","width=605,height=470,left=400,top=230");
});

//다음버튼
$("#main_arrow_next").click(function(){
	if(${requestScope.orderSize==requestScope.reviewOrder}){
		if(confirm("마지막 페이지 입니다. 상세요리페이지를 더 추가하겠습니까?")){
			location.href="recipe.do?command=update_plus&reviewOrder=${requestScope.reviewOrder}";
		}
		return false;
	}else{
		if("${requestScope.temSaveIs}"!="임시저장"){
			alert("임시저장 버튼을 누르세요");
			return false;
		}
		location.href="recipe.do?command=updateDesc&page=next";
	}
});

//이전버튼
$("#main_arrow_prev").click(function(){
	if("${requestScope.temSaveIs}"!="임시저장"){
		alert("임시저장 버튼을 누르세요");
		return false;
	}
	if(${requestScope.reviewOrder==1}){
		location.href="recipe.do?command=update_move&page=3";
	}else{
		location.href="recipe.do?command=updateDesc&page=prev";
	}
});

$("#main_ok").click(function(){
	if("${requestScope.temSaveIs}"!="임시저장"){
		alert("임시저장 버튼을 누르세요");
		return false;
	}
	if(confirm("수정 하시겠습니까?")){
		$("input[name=command]").val("update_submit");
		$("#pForm_4").submit();
	}
});
// 작성 취소 버튼
$("#main_cancle").click(function(){
	if(confirm("작성을 취소하시겠습니까?")){
		location.href="recipe.do?command=write_cancle";
	}
});
//임시 저장 버튼
$("#temSave").click(function(){
	$("input[name=command]").val("temSave");
	$("#pForm_4").submit();
});

});
	
</script>    
<div id="write_container">
<!-- 공통부분 -->
<div id="main_page1"><img src="${initParam.root }/img/main/main-write4-ing.gif"></div>
<div id="main_arrow_prev"><input type="image" src="${initParam.root }/img/main/main-write-prev.gif"></div>
<div id="main_arrow_next"><input type="image" src="${initParam.root }/img/main/main-write-next.gif"></div>
<div id="main_info_prev"><img src="${initParam.root }/img/main/main-write-prev-info.jpg"></div>
<div id="main_info_next"><img src="${initParam.root }/img/main/main-update-next-info.gif"></div>
<div id="main_ok"><input type="image" src="${initParam.root }/img/main/main-update-ok.gif"></div>
<div id="main_cancle"><input type="image" src="${initParam.root }/img/main/main-update-cancle.gif"></div>
<!-- 여기부턴 이 페이지에서만 쓰임 -->
<div id="main_confirm"><input type="text" id="main_confirm_text" value="${requestScope.reviewOrder+3}"></div>
	<div id="main_write_form">
		<!-- 데이터 전송용 폼 -->
 		<form id="pForm_4" action="recipe.do" >
 			<input type="hidden" name="command" value="updateDesc">
 			<input type="hidden" name="page" value="next">
 			<input type="hidden" name="temSaveIs" value="false">
 			<input type="hidden" name="r_img_origin" id="r_img_origin" value="${sessionScope.recipeContent.list[reviewOrder-1].r_img_origin}">
 			<input type="hidden" name="r_img_new" id="r_img_new" value="${sessionScope.recipeContent.list[reviewOrder-1].r_img_new}">
 			<input type="hidden" name="r_img_thum" id="r_img_thum" value="${sessionScope.recipeContent.list[reviewOrder-1].r_img_thum}">
 			<div id="main_title"><input type="text" id="main_subject_text" name="r_subject" value="${sessionScope.recipeContent.list[reviewOrder-1].r_subject}"/></div>
 			<div id="main_img" align="center"><img src="${initParam.root }/img/main/main-write-img.jpg" name="r_uploadFile" id="r_uploadFile" style="cursor: pointer;"></div>
 			<div id="main_comment"><pre><textarea id="main_content_text" cols="75" rows="7" name="r_content" >${sessionScope.recipeContent.list[reviewOrder-1].r_content}</textarea></pre></div>
 			<div class="main_temSave"><img src="${initParam.root }/img/main/main-update-temp.gif" id="temSave"></div>
		 </form>
 	</div>
</div>